// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetManageApi'

import AddClass from '@api/equipment/model/AssetImportByDeviceReq'
import ChildClass from '@api/equipment/model/DeviceInfo'
import BaseClass from '@api/equipment/model/AssetDto'
import FileClass from '@api/equipment/model/AssetFileDto'
import PropertyClass from '@api/equipment/model/AssetPropertyDto'

const CLIENT = CORE.grpcCLIENT(Client)

const CHILDREN = [ChildClass, 'deviceInfo', 1]

const FILE = [FileClass, 'assetFileList', 1]
const PROPERTY = [PropertyClass, 'assetPropertyDto', 1]
const BASE = [BaseClass, 'assetInfo', '', (dto, obj) => CORE.grpcDTO(dto, obj, FILE, PROPERTY)]

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 增 —————————————————————————————— //

  async add(one, TIP = '设备台账导入') {
    const DTO = CORE.grpcDTO(AddClass, one, BASE, CHILDREN)
    await CORE.grpc(TIP, CLIENT, 'importAssetByDevice', DTO)
    return CORE.grpcOK(TIP)
  },
}
